﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="True" CodeBehind="SearchContent.aspx.cs" Inherits="Cms.Web.UI.Admin.SearchContent" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="Stylesheet" href="Admin/Css/List.css" type="text/css" />
    <script language="javascript">
        //<![CDATA[
        function initList() {
            cms.Lists.Init("contentPane", prepareContentPopup);
            $(".popup").each(function () {
                cms.Lists.CreateListPopupMenu(this);
            });
            window.setTimeout(function () {
                cms.Lists.HidePaneOverlays();
                searchEnabled = true;
            }, 5000);
        }

        function prepareContentPopup(trigger, id, name, e) {
            var popup = document.getElementById("pnlContentPopup");
            var hlEdit = document.getElementById("hlEdit");
            hlEdit.href = "Admin/EditContentPreview.aspx?id=" + id.substring(1);
            document.getElementById("ctl00_body_hidSelectedContentID").value = id;
            cms.Lists.CurrentName = name;
            cms.Lists.ShowPopup(popup, trigger, "left", 0, 0, true, e);
        }

        function iframeLoaded() {
            document.getElementById("contentPaneOverlay").style.height = "100%";
        }

        $(window).load(function () {
            //alert("loaded!");
            cms.Lists.HidePaneOverlays();
            searchEnabled = true;
        });


        var searchEnabled = true;

        function prepareSearch() {
            if (cms.Ajax.IsInAsyncPostBack() || (document.getElementsByTagName("iframe").length > 1 && !searchEnabled)) {
                return false;
            }
            var chkShowPreviews = document.getElementById("ctl00_body_chkShowPreviews");
            if (chkShowPreviews.checked) {
                searchEnabled = false;
                return true;
            }
            searchEnabled = false;
            cms.Lists.ShowPaneOverlay('contentPaneOverlay');
            return true;
        }
        //]]>
    </script>
    <style type="text/css">
        .contentListPreview { border: 1px solid #ccd; margin-left: 7px; }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="buttons" runat="server">
    <asp:UpdatePanel ID="upnlButtons" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
            <asp:Panel ID="pnlButtonActions" runat="server" />
            <asp:hyperlink ID="hlNew" runat="server" CssClass="orangeButton"><span id="lblView1" runat="server"><span id="lblView2" runat="server"><img id="imgView" runat="server" src="Admin/Img/icons/page_white_add.png" alt="" /><span id="lblView3" runat="server"><cms:LocalizedLiteral ID="llNew" runat="server" /></span></span></span></asp:hyperlink>
            <asp:HyperLink ID="hlCancel" runat="server" CssClass="orangeButton"><span><span><img src="Admin/Img/icons/delete.png" alt="" /><span><cms:LocalizedLiteral ID="llCancel" runat="server" /></span></span></span></asp:HyperLink>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="body" runat="server">
    <asp:Literal ID="litIcon" runat="server" Visible="false" Text="Admin/Img/Icons/page_white_magnify.png" />
    <asp:UpdatePanel ID="upnlContent" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
        <ContentTemplate>
            <input type="hidden" id="hidNotLoadedPreviewsCount" runat="server" />
            <table>
                <tr>
                    <td><cms:LocalizedLiteral ID="llLocale" runat="server" />:</td>
                    <td><asp:DropDownList ID="ddlLocales" runat="server" /></td>
                    <td style="padding-left: 15px;"><cms:LocalizedLiteral ID="llCategory" runat="server" />:</td>
                    <td><ilib:iDropDownList ID="ddlCategories" runat="server" /></td>
                    <td style="padding-left: 15px;"><cms:LocalizedLiteral ID="llContentName" runat="server" />:</td>
                    <td><asp:TextBox ID="txtContentName" runat="server" /></td>
                </tr>
            </table>
            <table>
                <tr>
                    <td><cms:LocalizedLiteral ID="llMasterTemplate" runat="server" />:</td>
                    <td><asp:DropDownList ID="ddlMasterTemplates" runat="server" /></td>
                    <td style="padding-left: 15px;"><cms:LocalizedLiteral ID="llSortMode" runat="server" />:</td>
                    <td>
                        <asp:DropDownList ID="ddlSortModes" runat="server" />
                    </td>
                    <td style="padding-left: 15px;"><cms:LocalizedLiteral ID="llSortDirection" runat="server" />:</td>
                    <td>
                        <asp:DropDownList ID="ddlSortDirections" runat="server" />
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td><cms:LocalizedLiteral ID="llPageSize" runat="server" />:</td>
                    <td>
                        <asp:DropDownList ID="ddlPageSizes" runat="server">
                            <asp:ListItem Value="5">5</asp:ListItem>
                            <asp:ListItem Value="10">10</asp:ListItem>
                            <asp:ListItem Value="20">20</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td style="padding-left: 15px;">
                        <table>
                            <tr>
                                <td style="padding-right: 0px;"><asp:CheckBox ID="chkShowPreviews" runat="server" Checked="true" /></td>
                                <td><cms:LocalizedLiteral ID="llShowPreviews" runat="server" /></td>
                            </tr>
                        </table>
                    </td>
                    <td><asp:LinkButton ID="lbSearch" runat="server" OnClick="lbSearch_Click" OnClientClick="return prepareSearch();" CssClass="orangeButton"><span><span><img src="Admin/Img/icons/page_white_magnify.png" alt="" /><span><cms:LocalizedLiteral ID="llSearch" runat="server" /></span></span></span></asp:LinkButton></td>
                </tr>
            </table>
            <div class="horizontalDivider" style="margin-bottom: 17px; margin-top: 14px; margin-left: 1px; margin-right: 3px;"></div>
            <div id="contentPane" style="position: relative;">
                <asp:Panel ID="pnlActions" runat="server" />
                
            <asp:Panel ID="pnlUpper" runat="server">
                <ilib:iPagedNavigation ID="upperPages" runat="server" Template="~/Admin/PagedNavigationTemplate.ascx"
                    OnClick="PagedNavigation_Click" OnReady="PagedNavigation_Ready" />
                <div class="horizontalDivider" style="margin-bottom: 17px; margin-top: 14px; margin-left: 1px; margin-right: 3px;"></div>
            </asp:Panel>

                <asp:Panel ID="pnlPreviews" runat="server">
                    <table class="list" width="100%">
                        <asp:Repeater ID="rpContentWithPreviews" runat="server" OnItemDataBound="rpContentWithPreviews_ItemDataBound">
                            <ItemTemplate>
                                <tr>
                                    <td><asp:Literal ID="litID" runat="server" /><img src="Admin/Img/icons/page_white_edit.png" /><span style="font-size: 18px;"><asp:literal ID="litName" runat="server" /></span></span></td>
                                </tr>
                                <tr>
                                    <td style="padding-left: 8px;">
                                        <cms:LocalizedLiteral ID="llCategoriesHeader2" runat="server" />: <asp:Literal ID="litCategories" runat="server" />
                                        |
                                        <cms:LocalizedLiteral ID="llSortKeyHeader2" runat="server" />: <asp:Literal ID="litSortKey" runat="server" />
                                        |
                                        <asp:Literal ID="litCreated" runat="server" />
                                        |
                                        <cms:LocalizedLiteral ID="llSystemIDHeader" runat="server" />: <asp:Literal id="litSystemID" runat="server" />
                                        |
                                        <asp:Literal ID="litPublishedDate" runat="server" />
                                    </td>
                                                                             
                                </tr>
                                <tr>
                                    <td style="padding-top: 4px;">
                                        <div class="contentListPreview">
                                            <iframe id="ifrContentPreview" runat="server" frameborder="0" class="contentPreview" scrolling="no" height="20"></iframe>
                                        </div>
                                    </td>
                                </tr>
                            </ItemTemplate>
                            <SeparatorTemplate>
                                <tr>
                                    <td>
                                        <div class="horizontalDivider" style="margin-bottom: 17px; margin-top: 14px; margin-left: 1px; margin-right: 3px;"></div>
                                    </td>
                                </tr>
                            </SeparatorTemplate>
                        </asp:Repeater>
                        <tr id="trNoHits1" runat="server">
                            <td><cms:LocalizedLiteral ID="llNoHits1" runat="server" /></td>
                        </tr>
                    </table>
                </asp:Panel>
                <asp:Panel ID="pnlList" runat="server">
                    <table class="list">
                        <tr>
                            <th><cms:LocalizedLiteral ID="llNameHeader" runat="server" /></th>
                            <th><cms:LocalizedLiteral ID="llCategoriesHeader" runat="server" /></th>
                            <th><cms:LocalizedLiteral ID="llSortKeyHeader" runat="server" /></th>
                            <th><cms:LocalizedLiteral ID="llPublishedDateHeader" runat="server" /></th>
                            <th><cms:LocalizedLiteral ID="llCreatedHeader" runat="server" /></th>
                            <th><cms:LocalizedLiteral ID="llSystemIDHeader2" runat="server" /></th>
                        </tr>
                        <asp:Repeater ID="rpContentList" runat="server" OnItemDataBound="rpContentList_ItemDataBound">
                            <ItemTemplate>
                                <tr>
                                    <td><asp:Literal ID="litID" runat="server" /><img src="Admin/Img/icons/page_white_edit.png" /><span><asp:literal ID="litName" runat="server" /></span></span></td>
                                    <td><asp:Literal ID="litCategories" runat="server" /></td>
                                    <td><asp:Literal ID="litSortKey" runat="server" /></td>
                                    <td><asp:Literal ID="litPublishedDate" runat="server" /></td>
                                    <td><asp:Literal ID="litCreated" runat="server" /></td>
                                    <td><asp:Literal id="litSystemID" runat="server" /></td>
                                </tr>
                            </ItemTemplate>
                        </asp:Repeater>
                        <tr id="trNoHits2" runat="server">
                            <td colspan="3"><cms:LocalizedLiteral ID="llNoHits2" runat="server" /></td>
                        </tr>
                    </table>
                </asp:Panel>
                <div class="horizontalDivider" style="margin-bottom: 17px; margin-top: 14px; margin-left: 1px; margin-right: 3px;"></div>
                <asp:Panel ID="pnlLower" runat="server">
                    <ilib:iPagedNavigation ID="lowerPages" runat="server" Template="~/Admin/PagedNavigationTemplate.ascx"
                        OnClick="PagedNavigation_Click" OnReady="PagedNavigation_Ready" />
                    <div class="horizontalDivider" style="margin-bottom: 17px; margin-top: 14px; margin-left: 1px; margin-right: 3px;"></div>
                </asp:Panel>
                <div id="contentPaneOverlay" class="paneOverlay" style="height: 100%;"></div>
                <div id="contentPaneOverlayProgress" class="paneOverlayProgress"><img src="Admin/img/progress.gif" /></div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdatePanel ID="upnlActions" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
        <ContentTemplate>
            <div id="pnlContentPopup" class="popup">
                <asp:LinkButton ID="lbSelect" runat="server" OnClick="lbSelect_Click" OnClientClick="cms.Dialogs.ShowOverlay();"><img id="imgSelect" runat="server" src="Admin/Img/icons/page_white_go.png" /><span id="lblSelect" runat="server"><cms:LocalizedLiteral ID="llSelect" runat="server" /></span></asp:LinkButton>
                <a id="hlEdit" href="#"><img src="Admin/Img/icons/page_white_edit.png" /><span><cms:LocalizedLiteral ID="llEdit" runat="server" /></span></a>
                <div class="horizontalDivider" style="margin-bottom: 3px; margin-top: 4px; margin-left: 27px; margin-right: 4px;"></div>
                <asp:LinkButton ID="lbDelete" runat="server" OnClick="lbDelete_Click"><img id="imgDelete" runat="server" src="Admin/Img/icons/cross.png" /><span id="lblDelete" runat="server"><cms:LocalizedLiteral ID="llDelete" runat="server" /></span></asp:LinkButton>
            </div>
            <input type="hidden" id="hidSelectedContentID" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <script language="javascript">
        var chkShowPreviews = document.getElementById("ctl00_body_chkShowPreviews");
        if (chkShowPreviews.checked)
            cms.Lists.ShowPaneOverlay('contentPaneOverlay');
        iLib.Dom.AddListener(window, "load", initList);
        cms.Ajax.Init();
        cms.Ajax.AddEndRequestHandler(function () {
            var chkShowPreviews = document.getElementById("ctl00_body_chkShowPreviews");
            if (chkShowPreviews.checked && document.getElementsByTagName("iframe").length > 1) {
                // The overlay will be hidden when all iframes are done loading
                cms.Lists.ShowPaneOverlay('contentPaneOverlay');
            }
            else {
                searchEnabled = true;
                cms.Lists.HidePaneOverlays();
            }
        });
    </script>
</asp:Content>
